package Demo;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Admin
 * Date: 2022-04-26
 * Time: 20:50
 */
class Animal <T extends Comparable<T>>{

    public T Max(T[] array) {
        T max = array[0];
        for (int i = 0; i < array.length; i++) {
            if (max.compareTo(array[i]) < 0) {
                max = array[i];
            }
        }
        return max;
    }
}

class Fax  implements Comparable <Fax>{
    public int age;
    public String name;

    public Fax(int age, String name) {
        this.age = age;
        this.name = name;
    }

    @Override
    public int compareTo(Fax o) {
        return this.age-o.age;
    }

    @Override
    public String toString() {
        return "Fax{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }
}
public class TestDemo {
    public static void main(String[] args) {
        Integer[] array ={1,2,3,4,5,6,7};
        Animal<Integer> animal= new Animal<>();
        Integer input = animal.Max(array);
        System.out.println(input);

        Animal<Fax>  animal1= new Animal<>();
        Fax[] fax = new Fax[3];
        fax[0] = new Fax(18,"we");
        fax[1] = new Fax(20,"dk");
        fax[2] = new Fax(22,"cc");
        Fax fax1=animal1.Max(fax);
        System.out.println(fax1);

    }
}